﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GRC_TPE_WebApp.Controller;
using System.Web.Security;

namespace GRC_TPE_WebApp.View
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Méthode déclenchée au clic sur le bouton de connexion
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void B_Connect_Click(object sender, EventArgs e)
        {
            string[] result = UserController.Connect(this.TB_Username.Text, this.TB_Password.Text);
            string[] completeUser = null;

            if (result != null)
            {
                completeUser = new string[5];
                completeUser[0] = result[0];
                completeUser[1] = result[1];
                completeUser[2] = result[2];
                completeUser[3] = this.TB_Username.Text;
                completeUser[4] = result[3];
                Session.Add("User", completeUser);

                Response.Redirect("~/View/Private/Home.aspx");
            }
        }
    }
}